package com.dididoctor.patient.Activity.Capture;

import android.content.Context;

import com.dididoctor.patient.Activity.ConstantValue;
import com.dididoctor.patient.Bean.Token;
import com.dididoctor.patient.Http.MyHttpResponseHandler;
import com.dididoctor.patient.MV.BasePresenter;
import com.dididoctor.patient.MV.BusinessClient;
import com.dididoctor.patient.MV.Response;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;

/**
 * @version 2.0
 * @类描述：
 * @项目名称：ddgh
 * @类名称： LoginPresenter
 * @包名称： com.doudoukeji.service.Activity.Login
 * @创建人： zhanjunjie
 * @创建时间：2016/3/14 15:06
 * @修改人：
 * @修改时间：2016/3/14 15:06
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class CapturePresenter extends BasePresenter {

    private CaptureView captureView;
    private Context context;

    public CapturePresenter(Context context, CaptureView view) {
        super(context, view);
        this.captureView = view;
        this.context = context;
    }


    public void getCollection(String doctorId) {
        RequestParams params = new RequestParams();
        params.put("userId", Token.getId());
        params.put("token", Token.getToken());
        params.put("hospitalId", doctorId);
        BusinessClient.post(ConstantValue.collect, params, new MyHttpResponseHandler() {

            @Override
            public void onMyResponse(Response response) {
                if (response.isSucceed()) {
                    captureView.succesed(response.getString("doctorName"));
                } else {
                    captureView.fail();
                }
            }

            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                super.onFailure(i, headers, bytes, throwable);
                captureView.fail();
            }
        });
    }
}
